package cn.com.generaldata.os.service.indicator_evaluation.national_economy_contribution;

import org.apache.commons.lang3.Validate;

import cn.com.generaldata.jsme_indicator_system.entity.IndicatorEvaluation;
import cn.com.generaldata.jsme_indicator_system.util.Constants;
import cn.com.generaldata.os.service.indicator_constant.ProvinceIndicatorConstant;
import cn.com.generaldata.os.service.indicator_evaluation.IndicatorEvaluationCalculateService;
import cn.com.generaldata.os.vo.IndicatorAccountVO;

/**
 * 涉海就业比重评估指标计算类.
 */
public class OceanRelatedEmployedRateCalculateService extends IndicatorEvaluationCalculateService {

	private String oceanRelatedEmployedRateIndicatorName = ProvinceIndicatorConstant.OCEAN_EMPLOYED_RATE_INDICATOR_NAME;

	private String oceanEmployedIndicatorName = ProvinceIndicatorConstant.OCEAN_EMPLOYED_INDICATOR_NAME;

	private String employedIndicatorName = ProvinceIndicatorConstant.EMPLOYED_INDICATOR_NAME;

	@Override
	protected Double calculate(IndicatorEvaluation indicator, IndicatorAccountVO indicatorAccountVO) {
		Double result = null;
		if (indicator.getSection() == Constants.INDICATOR_LEVEL_PROVINCE) {
			result = calculateResult(indicatorAccountVO);
		} else if (indicator.getSection() == Constants.INDICATOR_LEVEL_CITY) {
			result = calculateResult(indicatorAccountVO);
		} else {
			// 县指标没确定先保留
		}
		return result;

	}

	/**
	 * 计算市级就业人员比重
	 * 
	 * @param indicatorAccountVO
	 * @return
	 */
	@SuppressWarnings("null")
	private Double calculateResult(IndicatorAccountVO indicatorAccountVO) {
		Double oceanEmployed = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear(),
				oceanEmployedIndicatorName);
		Validate.isTrue(oceanEmployed != null);

		Double employed = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear(),
				employedIndicatorName);
		Validate.isTrue(employed != null);

		return oceanEmployed / employed * 100;
	}

	// private Double calculateProvinceResult(IndicatorAccountVO indicatorAccountVO) {
	// // Integer oceanRelatedEmployedRateIndicatorId = getIndicatorInputId(oceanRelatedEmployedRateIndicatorName, 5);
	// Double oceanRelatedEmployedRate =
	// getInputOrAccountingIndicatorValue(indicatorAccountVO,indicatorAccountVO.getYear(),oceanRelatedEmployedRateIndicatorName);
	//
	//
	// if (Double.valueOf(0).equals(oceanRelatedEmployedRate)) {
	// return Double.valueOf(0);
	// }
	// return oceanRelatedEmployedRate;
	// }

}
